var $objload ;
var floatX,floatY,boxX,boxY,pageX,pageY;
var cX = document.documentElement.clientWidth;
var cY = document.documentElement.clientHeight;
$(document).ready(function(){
    $objload = $("#objload");
    $objload.css("height","200px");
	$("td[@name*=statdata_]").hover(function(){
		$(this).mousemove(function(event){
	    pageX = event.clientX + $(window).scrollLeft();
		pageY = event.clientY + $(window).scrollTop();
	    boxX = $('#objload').outerWidth(true);
	    boxY = $('#objload').outerHeight(true);
		if ((cX - event.clientX) < (boxX + 35)){
	      floatX = pageX - boxX + 55;
		}else{
	      floatX = pageX + 85;
		}
	    if ((cY - event.clientY) < (boxY + 10)){
		  floatY = pageY - boxY - 10;
	    }else{
		  floatY = pageY + 10;
		}
         $("td[@name*=statdata_]").removeClass("curSpan");
         var d = eval($(this).attr("d").toString());
         var em = $(this).attr("name").trim();
         var curCode = d.code;
         var curName = $(this).html();
         var minPrice = 999;
         var maxPrice = 0;
         var curPrice = d.price;
            var aprice = 0;
        var big = 0;
        var small = 0;
        var sumRange = 0;
        var scale = 0;
         $("td[@name="+em+"]").addClass("curSpan");
         var days = 0,percent=0;
         $("td[@name="+em+"]").each(function(index){
             days++;
             var vo = eval($(this).attr("d").toString());
             aprice = parseFloat(vo.price);
             big += parseFloat(vo.big);
             small += parseFloat(vo.small);
             sumRange += Number(vo.crange);
             scale += Number(vo.scale);
             minPrice = minPrice>curPrice? aprice:minPrice;
             maxPrice = maxPrice>curPrice? aprice:curPrice;
         });
        percent = percent/days;
        var info = "<div style='width:100%;heigth:20px;background:#8B0000;text-align:center'>" + document.title + "</div>"
                + "代码:" + curCode
                + "<br/>股票:" + curName
                + "<br/>统计出现：" + days + "次"
                + "<br/> 大单流入:" + big.toString().substring(0,8) + "[万]"
                   + "<br/> 小单流出:" + small.toString().substring(0,8) + "[万]"
                + "<br/> 涨幅:" + sumRange.toString().substring(0,4)+"%"
                   + "<br/> 最高价:" + maxPrice.toString().substring(0,8)+"" 
                   + "<br/> 最低价:" + minPrice.toString().substring(0,8)+""
                   + "<br/> 当前价:" + curPrice.toString().substring(0,8)+""
            + "<br/> 大小单比例:" + (scale/days).toString().substring(0,8)+"" ;
        $objload.html(info).css({top: floatY, left: floatX}).show();
  });},function(){
	   $objload.hide();
        $("td[@name*=statdata_]").removeClass("curSpan")
	  })
	$(window).resize(function() {
	cX = document.documentElement.clientWidth;
	cY = document.documentElement.clientHeight;
	});
})